package com.weixin.app;

import io.appium.java_client.android.AndroidDriver;

import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;

public class ConTactPage extends BasePage{

    public ConTactPage(AndroidDriver driver) throws MalformedURLException {
        super(driver);
    }

    //跳转到成员详情页面
    public MemberPage toMemberPage() throws MalformedURLException {
        return new MemberPage(driver);
    }

    //添加成员
    public ConTactPage addMember(Userfiles userfiles) throws Exception {

        find("id","kcc").click();
        find("xpath","//*[@text='添加成员']").click();
        find("xpath","//*[@text='手动输入添加']").click();
        find("id","bsm").sendKeys(userfiles.getName());
        find("id","hgi").sendKeys(userfiles.getPhone());
        find("xpath","//*[@text='保存']").click();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        find("id","kbo").click();
       // driver.navigate().back();
        find("id","kc8").click();
        return this;
    }

    //查询成员
    public MemberPage searchMember(String name) throws Exception {
        find("id","kci").click();
        find("xpath","//*[@text='搜索']").sendKeys(name);
        find("id","fkc").click();
        return new MemberPage(driver);
    }

    //添加子部门
    public ConTactPage addPartment(Partmentfils partmentfils) throws Exception {
        find("id","kcc").click();
        find("xpath","//*[@text='添加子部门']").click();
        find("id","cee").sendKeys((CharSequence) partmentfils.getPartment());
        find("id","ceq").click();

        return this;

    }

    //查询子部门
    public PartmentPage seartPartment(Partmentfils partmentfils) throws Exception {
        find("id","f0m").click();
        //driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        find("xpath","//*[@text='设置部门']").click();
        find("id","kcc").click();
        find("id","iqz").sendKeys((CharSequence) partmentfils.getPartment());
        return new PartmentPage(driver);
    }
}
